﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link href="static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css"/>
    <link href="static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css"/>
    <link href="static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>后台登录v1.0</title>
    <meta name="keywords" content="H-ui.admin v3.0,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
    <meta name="description"
          content="H-ui.admin v3.0，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">

</head>
<body>
<input type="hidden" id="TenantId" name="TenantId" value=""/>
<div class="header"></div>
<div id="app" class="loginWraper">

    <div id="loginform" class="loginBox">
        <h5 style="text-align: center;margin: 0px auto;padding: 0px;color:cornflowerblue;font-weight: bolder;">
            用户登录</h5>
        <div class="form form-horizontal">
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
                <div class="formControls col-xs-8">
                    <input id="username" name="identify" v-model="loginUser.identify" type="text" placeholder="账户"
                           class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
                <div class="formControls col-xs-8">
                    <input id="password" name="password" type="password" v-model="loginUser.password" placeholder="密码"
                           class="input-text size-L">
                </div>
            </div>
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <input class="input-text size-L" type="text" id="randomCode" placeholder="验证码"  style="width:120px;" v-model="randomCode">
                    <img :src="randomCodeUrl" id="randomCodeImage" style="width: 120px"> <a id="kanbuq"  href="#" @click="refreshRandomCodeImageUrl">看不清楚换一张</a>
                </div>
            </div>
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <label for="online">
                        <input type="checkbox" name="online" id="online"  v-model="rememberMe" :value="rememberMe">
                        记住我</label>
                </div>
            </div>
            <div class="row cl">
                <div class="formControls col-xs-8 col-xs-offset-3">
                    <!--
                    <input name="" type="submit" class="btn btn-success radius size-L"
                           value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;">
                    -->
                    <input name="" type="button" @click="doLogin" class="btn btn-success radius size-L"
                           value="登  录">
                    <input name="" type="reset" class="btn btn-default radius size-L"
                           value="取  消">
                    &nbsp;&nbsp;<a href="reg.html">立即注册</a>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="footer"> &copy; 华清远见 2017-2023 &nbsp;&nbsp; 作者: 西蒙牛 v1.0</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<!--此乃百度统计代码，请自行删除-->
<!--引入基础的公共类库-->

<script src="include/commons.js"></script>

<script src="auth/auth.js"></script>
<script src="uitl/outils.min.js"></script>
<script src="uitl/encrypt.js"></script>


<script type="module">
    if (await checkLogin()) {
        console.log("已登录....");
        window.location.href = 'index.html';
    } else {
        console.log('未登录....')
    }
</script>

<script type="module">
    //引入前端nanoid令牌生成工具类库
    import {nanoid} from "./uitl/nanoid.js";

    let vm = new Vue({
        el: '#app',
        data: {
            token: nanoid(16),
            randomCode: '',
            randomCodeUrl: '',
            loginUser: {
                identify: '',
                password: ''
            },
            rememberMe: true,
        },
        mounted() {
            //读取cookie初始化用户名和密码
            if(outils.getCookie("username.bigdata.com")!==null){
                this.loginUser.identify = decrypt(outils.getCookie("username.bigdata.com"));
                this.loginUser.password = decrypt(outils.getCookie("password.bigdata.com"));
            }
            console.log('本页面的客户端token:' + this.token);
            this.refreshRandomCodeImageUrl();
        },
        methods: {
             //更新图形验证码接口的URL地址
            refreshRandomCodeImageUrl() {
                this.randomCodeUrl = baseUrl + '/commons/hutool/randomCode?token=' + this.token + '&tm=' + new Date().getTime();
            },
            doLogin() {
                console.log('执行用户登录....');
                console.log(this.loginUser);
                let param = {
                    identify: this.loginUser.identify,
                    password: this.loginUser.password,
                    token: this.token,
                    code: this.randomCode
                }

                login(param).then(resp => {
                    //console.log(resp);
                    if (resp.data.code === 200) {

                        //在登录成功之后，判断用户是否需要记住我。
                        if(this.rememberMe){
                            outils.setCookie("username.bigdata.com", encrypt(this.loginUser.identify),100);
                            outils.setCookie("password.bigdata.com", encrypt(this.loginUser.password),100);
                        }else{
                            outils.removeCookie("username.bigdata.com");
                            outils.removeCookie("password.bigdata.com");
                        }

                        this.$message({
                            message: resp.data.msg,
                            type: 'success'
                        });
                        localStorage.setItem("loginStatus.web.bigdataproject", true);
                        window.setTimeout(() => {
                            window.location.href = 'index.html';
                        }, 1000);

                    } else {
                        //console.log(resp.data.msg);
                        this.$message({
                            message: resp.data.msg,
                            type: 'error'
                        });
                    }
                })

            }
        }

    })


</script>
<!--/此乃百度统计代码，请自行删除
</body>
</html>